package com.ruoyi.web.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.PaymentLimitResult;
import com.ruoyi.web.service.IPaymentLimitResultService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 代付限额申请查询Controller
 * 
 * @author ruoyi
 * @date 2021-04-04
 */
@Controller
@RequestMapping("/pay/limitresult")
public class PaymentLimitResultController extends BaseController
{
    private String prefix = "pay/limitresult";

    @Autowired
    private IPaymentLimitResultService paymentLimitResultService;

    @RequiresPermissions("pay:limitresult:view")
    @GetMapping()
    public String limitresult()
    {
        return prefix + "/limitresult";
    }

    /**
     * 查询代付限额申请查询列表
     */
    @RequiresPermissions("pay:limitresult:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PaymentLimitResult paymentLimitResult)
    {
        startPage();
        List<PaymentLimitResult> list = paymentLimitResultService.selectPaymentLimitResultList(paymentLimitResult);
        return getDataTable(list);
    }

    /**
     * 导出代付限额申请查询列表
     */
    @RequiresPermissions("pay:limitresult:export")
    @Log(title = "代付限额申请查询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PaymentLimitResult paymentLimitResult)
    {
        List<PaymentLimitResult> list = paymentLimitResultService.selectPaymentLimitResultList(paymentLimitResult);
        ExcelUtil<PaymentLimitResult> util = new ExcelUtil<PaymentLimitResult>(PaymentLimitResult.class);
        return util.exportExcel(list, "limitresult");
    }

    /**
     * 新增代付限额申请查询
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存代付限额申请查询
     */
    @RequiresPermissions("pay:limitresult:add")
    @Log(title = "代付限额申请查询", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PaymentLimitResult paymentLimitResult) throws Exception
    {
        return toAjax(paymentLimitResultService.insertPaymentLimitResult(paymentLimitResult));
    }

    /**
     * 修改代付限额申请查询
     */
    @GetMapping("/edit/{sequenceNo}")
    public String edit(@PathVariable("sequenceNo") String sequenceNo, ModelMap mmap)
    {
        PaymentLimitResult paymentLimitResult = paymentLimitResultService.selectPaymentLimitResultById(sequenceNo);
        mmap.put("paymentLimitResult", paymentLimitResult);
        return prefix + "/edit";
    }

    /**
     * 修改保存代付限额申请查询
     */
    @RequiresPermissions("pay:limitresult:edit")
    @Log(title = "代付限额申请查询", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PaymentLimitResult paymentLimitResult)
    {
        return toAjax(paymentLimitResultService.updatePaymentLimitResult(paymentLimitResult));
    }

    /**
     * 删除代付限额申请查询
     */
    @RequiresPermissions("pay:limitresult:remove")
    @Log(title = "代付限额申请查询", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(paymentLimitResultService.deletePaymentLimitResultByIds(ids));
    }
}
